{literal}
<style type="text/css">
    #spage_detail {border: 1px solid #C8C8C8;text-align: left;}
    #spage_detail .title {
        background: #FFF;
        border-bottom: 1px solid #C8C8C8;
        color: #fff;
        padding: 1px;
        text-align: left;
    }

    #edit_title {
        background: #0E5FB2;
        padding: 5px 4px 5px 10px;
        font-weight: 700;
        font-family: Tahoma, Verdana, Arial, serif;
    }

    #spage_detail .page_content {
        border: 1px solid #C8C8C8;
        padding: 5px;
        font-size: 12px;
        text-align: left;
    }
    #page_content{
        padding: 5px;
    }
</style>
{/literal}
<div id="spage_detail">
    <div class="title">
        <div id="edit_title">{$title} {if $edit} <button onclick="return edit_spage_content('{$key}')">Sửa</button>{/if}</div>
    </div>
    <div id="page_content">
        <div id="content" style="padding:5px">
        {$item}
        </div>


    </div>
{if $edit}
    <div id="NewsContent_edit" style="display: none;">
        <div id="ad_content_edit">
            <textarea id="editbody" rows="" cols="" name="body"></textarea>
            <button onclick="return edit_spage_save('{$key}');">Save</button>
            <button onclick="return edit_spage_cancel();">Cancel</button>
        </div>
    </div>
    {literal}
        <script type="text/javascript">

            tinyMCE.init({
                mode:"textareas",
                //mode : "exact",
                elements:"wysiwyg",
                theme:"advanced",
                invalid_elements:"div,script,img,abbr,acronym,address,applet,area,bdo,big,blockquote,button,caption,cite,code,col,colgroup,dd,del,dfn,iframe,input,ins,isindex,kbd,label,legend,map,menu,noscript,object,optgroup,option,param,textarea,var,ruby,samp,select,rtc",
                height:"300px",
                width:"100%",
                plugins:"paste,inlinepopups,xhtmlxtras",
                theme_advanced_buttons1:"code,bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist",
                theme_advanced_buttons2:"",
                theme_advanced_buttons3:"",
                theme_advanced_toolbar_location:"top",
                theme_advanced_toolbar_align:"left",
                theme_advanced_font_sizes:"3,4,5,6",
                theme_advanced_fonts:"Arial=arial;Verdana=verdana;Times New Roman=times new roman;Tahoma=tahoma",
                entity_encoding:"raw",
                language:'vi',
                theme_advanced_buttons1_add:"fontselect,fontsizeselect,forecolor,backcolor,separator,link,unlink,,pasteword,removeformat",
                theme_advanced_path_location:"bottom",
                theme_advanced_path:false,
                theme_advanced_resize_horizontal:false,
                theme_advanced_resizing:true
            });

            function edit_spage_content(id) {

                jQuery.jCache.maxSize = 10;
                //document.getElementById('loadingEditContentDiv').style.display = '';
                var cache_key = "ajax.php?act=item&code=load_spage_content&key=" + id;
                if (jQuery.jCache.hasItem(cache_key) && !load_jcache_edit_des) {
                    tinyMCE.activeEditor.setContent(jQuery.jCache.getItem(cache_key));
                }
                else {
                    jQuery.get(cache_key, function (data) {
                        tinyMCE.activeEditor.setContent(data);
                        load_jcache_edit_des = false;
                        jQuery.jCache.setItem(cache_key, data);
                    });
                }

                setTimeout(function () {
                    //document.getElementById('loadingEditContentDiv').style.display = 'none';
                    //document.getElementById('lbl_content_edit').style.display = 'none';
                }, 500);
                document.getElementById('page_content').style.display = 'none';
                document.getElementById('NewsContent_edit').style.display = '';
                return false;
            }

            function edit_spage_save(id) {
                var body_content = tinyMCE.get('editbody').getContent();
                var url_save = 'ajax.php?act=item&code=save_spage&key=' + id;
                var strData = '{body:' + body_content + '}';
                $.ajax({url:url_save, type:'post', data:{body:body_content}, dataType:'json', success:function (json) {
                    if (json.data == 'oke') {
                        document.getElementById('content').innerHTML = body_content;
                        document.getElementById('page_content').style.display = '';
                        document.getElementById('NewsContent_edit').style.display = 'none';
                    } else {
                        edit_spage_cancel();
                    }
                }});
                load_jcache_edit_des = true;
                return false;
            }
            function edit_spage_cancel() {
                document.getElementById('page_content').style.display = '';
                document.getElementById('NewsContent_edit').style.display = 'none';
                return false;
            }
        </script>
    {/literal}
{/if}
</div>
